/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author server
 */
@Entity
@Table(name = "Employees")
@NamedQueries({
    @NamedQuery(name = "Employees.findAll", query = "SELECT e FROM Employees e"),
    @NamedQuery(name = "Employees.findByEmpNoAndPassword", query = "SELECT e FROM Employees e WHERE e.empNo = :empNo AND e.password=:password"),
    @NamedQuery(name = "Employees.findByEmpName", query = "SELECT e FROM Employees e WHERE e.empName = :empName"),
    @NamedQuery(name = "Employees.changePass", query = "UPDATE Employees e SET e.password = :password WHERE e.empNo = :empNo"),
    @NamedQuery(name = "Employees.findByAddress", query = "SELECT e FROM Employees e WHERE e.address = :address"),
    @NamedQuery(name = "Employees.findByPhone", query = "SELECT e FROM Employees e WHERE e.phone = :phone"),
    @NamedQuery(name = "Employees.findByEmail", query = "SELECT e FROM Employees e WHERE e.email = :email"),
    @NamedQuery(name = "Employees.findByDepartID", query = "SELECT e FROM Employees e WHERE e.departments.departmentID = :departmentID"),
    @NamedQuery(name = "Employees.findByEmStatus", query = "SELECT e FROM Employees e WHERE e.emStatus = :emStatus")})
  
    public class Employees implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "EmpNo")
    private String empNo;
    @Column(name = "EmpName")
    private String empName;
    @Basic(optional = false)
    @Column(name = "Password")
    private String password;
    @Column(name = "Address")
    private String address;
    @Column(name = "Phone")
    private String phone;
    @Column(name = "Email")
    private String email;
    @Basic(optional = false)
    @Column(name = "EmStatus")
    private int emStatus;
    @JoinColumn(name = "DepartmentID", referencedColumnName = "DepartmentID")
    @ManyToOne(optional = false)
    private Departments departments;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "employees")
    private Collection<Interviews> interviewsCollection;

    public Employees() {
    }

    public Employees(String empNo) {
        this.empNo = empNo;
    }

    public Employees(String empNo, String password, int emStatus) {
        this.empNo = empNo;
        this.password = password;
        this.emStatus = emStatus;
    }

    public String getEmpNo() {
        return empNo;
    }

    public void setEmpNo(String empNo) {
        this.empNo = empNo;
    }

    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getEmStatus() {
        return emStatus;
    }

    public void setEmStatus(int emStatus) {
        this.emStatus = emStatus;
    }

    public Departments getDepartments() {
        return departments;
    }

    public void setDepartments(Departments departments) {
        this.departments = departments;
    }

    public Collection<Interviews> getInterviewsCollection() {
        return interviewsCollection;
    }

    public void setInterviewsCollection(Collection<Interviews> interviewsCollection) {
        this.interviewsCollection = interviewsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (empNo != null ? empNo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employees)) {
            return false;
        }
        Employees other = (Employees) object;
        if ((this.empNo == null && other.empNo != null) || (this.empNo != null && !this.empNo.equals(other.empNo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bean.entity.Employees[empNo=" + empNo + "]";
    }

}
